{# @sw-package framework #}

{% for violation in formViolations.getViolations(violationPath) %}
    {% if violation.messageTemplate starts with 'VIOLATION::' %}
        {% set snippetName = "error.#{violation.messageTemplate}" %}
    {% else %}
        {% set snippetName = "error.#{violation.code}" %}
    {% endif %}

    {% set fieldName = violationLabel ? violationLabel : violation.propertyPath|split('/')|last|trim('/', 'left')|capitalize %}
    <div class="invalid-feedback">
        {% if violation.parameters %}
            {% set violationParams = {'%field%': fieldName}|merge(violation.parameters) %}
        {% else %}
            {% set violationParams = {'%field%': fieldName} %}
        {% endif %}

        {{ snippetName|trans(violationParams)|sw_sanitize }}
    </div>
{% endfor %}
